package com.sky.mapper;

import com.sky.entity.ShoppingCart;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

@Mapper

public interface UserShoppingMapper {
    /**
     * 查询购物车食物
     * @param shoppingCart
     * @return
     */
    List<ShoppingCart> Select(ShoppingCart shoppingCart);

    /**
     * 修改购物车 UserID
     * @param shopping
     */
    void Update(ShoppingCart shopping);

    /**
     * 插入数据
     * @param shoppingCart
     */
    @Insert("insert into shopping_cart(name,image,user_id,dish_id,setmeal_id,dish_flavor,number,amount,create_time) values (" +
            "#{name},#{image},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount},#{createTime})")
    void Insert(ShoppingCart shoppingCart);

    /**
     * 清空数据 根据UserID
     * @param shoppingCart
     */
    @Delete("delete from shopping_cart where user_id=#{userId}")
    void deleteCart(ShoppingCart shoppingCart);


}
